package zzzhc.image.ui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import zzzhc.image.model.RecognizeTestModel;

public class RecognizeTestTableCellRenderer extends DefaultTableCellRenderer {

	private static final long serialVersionUID = -3288073173605840603L;

	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		String text = (String) value;
		String target = (String) ((RecognizeTestModel) (table.getModel()))
				.getValueAt(row, 0);
		if (column == 2) {
			boolean match = target.equals(text);
			JLabel label = new JLabel(text);
			if (match) {
				label.setForeground(Color.GREEN);
			} else {
				label.setForeground(Color.RED);
			}
			return label;
		} else {
			return super.getTableCellRendererComponent(table, value,
					isSelected, hasFocus, row, column);
		}
	}

}
